﻿using System;
using System.Collections.Generic;
using System.Text;
using SalePartial.IDAL;
using System.Data.SqlClient;
using SalePartial.Model;

namespace SalePartial.BLL
{
    public class XPUserProfile : IXPUserProfile
    {

        private IXPUserProfile dal = SalePartial.DALFactory.DataAccess.CreateXPUserProfile();


        //public void Create(XPUserProfileInfo userProfileInfo)
        //{
        //    dal.Insert(userProfileInfo);
        //}

        //public int CreateNew(XPUserProfileInfo userProfileInfo)
        //{
        //    return dal.Insert(userProfileInfo);
        //}

        public void Delete(XPUserProfileInfo userProfileInfo)
        {
            dal.Delete(userProfileInfo.UserID);
        }

        public XPUserProfileInfo GetXPUserProfile(Guid id)
        {
            SqlDataReader reader = this.SelectReader(id);
            XPUserProfileInfo info = new XPUserProfileInfo(reader);
            if (!reader.IsClosed)
            {
                reader.Close();
            }
            return info;
        }

        //public void Update(XPUserProfileInfo userProfileInfo)
        //{
        //    dal.Update(userProfileInfo);
        //}


        public int Delete(Guid UserID)
        {
            return dal.Delete(UserID);
        }

        public int DeleteByUserID(Guid UserID)
        {
            return dal.DeleteByUserID(UserID);
        }

        public int Insert(XPUserProfileInfo info)
        {
            return dal.Insert(info);
        }

        public System.Data.DataSet SelectAll()
        {
            return dal.SelectAll();
        }

        public System.Data.DataSet SelectByUserID(Guid UserID)
        {
            return dal.SelectByUserID(UserID);
        }

        public XPUserProfileInfo SelectInfoByUserID(Guid UserID)
        {
            SqlDataReader reader = this.SelectReaderByUserID(UserID);

             XPUserProfileInfo info = null;
            if (reader.Read())
            {
                info = new XPUserProfileInfo(reader);
            }
            if (!reader.IsClosed)
            {
                reader.Close();
            }
            return info;
        }

        public int SelectDynamic(string v_whereCondition)
        {
            return dal.SelectDynamic(v_whereCondition);
        }

        public System.Data.DataSet SelectDynamic(string v_whereCondition, string v_orderByExpression)
        {
            return dal.SelectDynamic(v_whereCondition, v_orderByExpression);
        }

        public System.Data.DataSet SelectPaged()
        {
            return dal.SelectPaged();
        }

        public System.Data.SqlClient.SqlDataReader SelectReader(Guid UserID)
        {
            return dal.SelectReader(UserID);
        }

        public System.Data.SqlClient.SqlDataReader SelectReaderByUserID(Guid UserID)
        {
            return dal.SelectReaderByUserID(UserID);
        }

        public System.Data.DataSet SelectSingle(Guid UserID)
        {
            return dal.SelectSingle(UserID);
        }

        public int Update(XPUserProfileInfo info)
        {
            return dal.Update(info);
        }
    }
}
